package cn.mw.cmdb.processor;

import cn.hutool.core.date.StopWatch;
import cn.mw.microMonitorCommon.security.utils.SecurityUtils;
import cn.mw.microMonitorCommon.util.SpringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class BusinessProcessNetworkListener implements ApplicationListener<BusinessProcessEvent> {

    @Override
    public void onApplicationEvent(BusinessProcessEvent event) {
        try {
            log.info("BusinessProcessNetworkListener ....");
            BusinessProcessNetwork businessProcessNetwork = SpringUtils.getBean(BusinessProcessNetwork.class);
            StopWatch stopWatch = new StopWatch();
            stopWatch.start();
            businessProcessNetwork.processInterfaceInfo(event);
            stopWatch.stop();
            log.info("processInterfaceInfo {}" ,stopWatch.prettyPrint());
        }catch (Exception e){
            log.error("processInterfaceInfo" ,e);
        }
    }
}
